﻿using System;
using System.IO;

namespace Bono.PhotoSorter
{
	public static class Utilities
	{
		public static class ImageFileExtensions
		{
			public const string Tif = "tif";
			public const string Tiff = "tiff";
			public const string Png = "png";
			public const string Jpg = "jpg";
			public const string Jpeg = "jpeg";
			public const string Gif = "gif";
			public const string Bitmap = "bmp";

			public static bool IsValid(string filePath)
			{
				//There's no need to check further if it's null or empty
				if (String.IsNullOrEmpty(filePath))
				{
					return false;
				}

				string extension = Path.GetExtension(filePath).Remove(0,1);
				if (String.Compare(extension, Tif, StringComparison.OrdinalIgnoreCase) == 0 ||
					 String.Compare(extension, Tiff, StringComparison.OrdinalIgnoreCase) == 0 ||
					 String.Compare(extension, Png, StringComparison.OrdinalIgnoreCase) == 0 ||
					 String.Compare(extension, Jpg, StringComparison.OrdinalIgnoreCase) == 0 ||
					 String.Compare(extension, Jpeg, StringComparison.OrdinalIgnoreCase) == 0 ||
					 String.Compare(extension, Gif, StringComparison.OrdinalIgnoreCase) == 0 ||
					 String.Compare(extension, Bitmap, StringComparison.OrdinalIgnoreCase) == 0)
				{
					return true;
				}

				return false;
			}
		}
	}
}
